import {observable, computed, asStructure, action} from 'mobx';

class UserInfoStore {
	
	@observable username = '';
	
	@observable password = '';
	
	@observable isLogin = false;
	
	@observable price = 100;
	@observable amount = 1;
	
	@computed get total() {
		return this.price * this.amount;
	}
	
	@action.bound
	doLogin() {
		this.isLogin = true;
		return this;
	}
	
	@action.bound
	doLogout() {
		this.isLogin = false;
		this.username = '';
		this.password = '';
		return this;
	}
	
	// constructor(key) {
	// 	this.key = key;
	// }
	//
	// @action.bound
	// setValue(key, value) {
	// 	this.username = value;
	// 	return this;
	// }
}

export default new UserInfoStore('global');